package com.cskaoyan.controller;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @author stone
 * @date 2022/03/25 11:03
 */
@RestController
public class UserController {

    //localhost:8080/login?username=songge&password=yuanzhi
    @RequestMapping("login")
    public String login(@RequestParam("username") String name,
                        @RequestParam("password") String pwd,@RequestParam("age")Integer age) {
        return "success";
    }

    @RequestMapping("header")
    public String header(@RequestHeader("Connection") String connection,
                         @RequestHeader("Accept")String[] accept) {
        return "success";
    }

    @RequestMapping("cookie")
    public String cookie(@CookieValue("ligenli") String value) {
        System.out.println(value);
        return "success";
    }

    @RequestMapping("session/put/{value}")
    public String put(@PathVariable("value")String value, HttpSession session) {
        session.setAttribute("password",value);
        return "success";
    }

    /*@RequestMapping("session/get")
    public String get(HttpSession session) {
        Object value = session.getAttribute("password");
        return "success";
    }*/
    @RequestMapping("session/get")
    public String get(@SessionAttribute("password")Object value) {
        return "success";
    }
}
